<template>
    <div class="cgs-switch no-select">
        <div class="cgs-switch-option" :class="{'cgs-switch-check': checked}" @click="checked = true; $emit('change', checked)">{{activeText}}</div>
        <div class="cgs-switch-option" :class="{'cgs-switch-check': !checked}" @click="checked = false; $emit('change', checked)">{{inactiveText}}</div>
    </div>
</template>

<script>
    export default {
        name: "CgsSwitch",
        model: {
            prop: 'checked',
            event: 'change'
        },
        props: {
            'active-text': {
                type: String,
                default: '是'
            },
            'inactive-text': {
                type: String,
                default: '否'
            },
            'active-color':{
                type: String,
                default: '#13ce66'
            },
            'checked':{
                type: Boolean,
                default: true
            }
        }
    }
</script>

<style scoped>
    .cgs-switch {
        width: 128px;
        height: 40px;
        display: flex;
        background: #273342;
        border-radius: 2px;
        border: 1px solid #747474;
        cursor: pointer;
        margin-left: 10px;
    }
    .cgs-switch-option {
        width: 50%;
        height: 100%;
        text-align: center;
        line-height: 40px;
        font-size: 14px;
        font-family: PingFangSC-Regular, PingFang SC;
        font-weight: 400;
        color: #B4B4B4;
    }
    .cgs-switch-option:hover {
        background: #89abfa;
        color: #FFFFFF;
    }
    .cgs-switch-check{
        background: #4C84FF;
        color: #FFFFFF;
    }
</style>
